{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 什么是决策树"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn import datasets\n",
    "\n",
    "iris = datasets.load_iris()\n",
    "X = iris.data[:,2:]\n",
    "y = iris.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAaMklEQVR4nO3df5BddXnH8fezd5cmBiSjWUwMYFADjgIa2eGHcZQpNSKkJLVGpbU1DpWOBcVJtSNORlOMox06aCpUJgoFKkUIYECCpVbaqsWk7gYllV9iUJMQyCLyIxhKsvv0j3uT7N49d+/33HP2/Lqf10wme8/93nOeC5MnJ+d8vt9j7o6IiJRfT94FiIhIOtTQRUQqQg1dRKQi1NBFRCpCDV1EpCJ68zrwrFmzfN68eXkdXkSklIaGhp509/6o93Jr6PPmzWNwcDCvw4uIlJKZ/arVe7rkIiJSEWroIiIVoYYuIlIRaugiIhWhhi4iUhFq6CIiFaGGLiJSEW1z6GZ2FHAdMBsYBda6+5qmMacDtwGPNjbd6u6XpFuqiJTdhq0bWLN5DY8//zizZ8zmojdfxNmvPjvR54FE+6ySkIlF+4C/dvfNZnYYMGRm33X3+5vG/cDdF6dfoohUwYatG1h1zypeGHkBgJ3P72TVPasAghpw1OdX/nAlZsbe0b0d7bNq2l5ycfed7r658fNzwAPA3KkuTESqZc3mNQea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n0jpmZiuAAeCl7r4473o6ZWa/BAbcvfQTcczsWuAH7v51MzsEeIm7P513XUk0VrTdAZzi7kkmW5bvDN3dv09FlhVw953uvrnx83PAA0xc+KwUvG5342Vf41e5zhbGMLMjgbOBr+ddi9SZ2UuBt1GfyIi7v1j2Zt5wBvCLpM0cStjQq6rxUJAFwKZ8K+lc4xLFT4BdwHfdvbTfBfgy8DfAaN6FpMCBfzOzITM7P+9iEng1MAz8U+NS2NfNbEbeRaXg/cANaexIDb0AzOxQ4Bbg4+7+bN71dMrdR9z9TdQXcDvZzEp5SczMFgO73H0o71pSstDd30z9ITUXNC5bllEv8Gbgq+6+AHgemPAEtTJpXDY6B1iXxv7U0HPWuN58C3C9u9+adz1paPwz+D+BM3MupVMLgXMa156/Cfy+mX0j35I65+6PNX7fBXyL+kNrymg7sH3Mv/xupt7gy+xdwGZ3fyKNnamh56hxI/Eq4AF3vyzvepIws34zm9n4eTrwB8CD+VbVGXe/2N2PdPd51P85fLe7fyDnsjpiZjMaN9xpXJ5YBJQyIebujwPbzOy4xqYzgNIFCJqcS0qXWyBwca4iMbMbgNOBWWa2Hfisu1+Vb1UdWwj8GbClce0Z4NONxdDKZg5wbeOOfQ9wk7uXOu5XEa8AvtV4ImQv8C/u/q/5lpTIR4HrG5cqtgIfyrmejpnZS4B3AH+Z2j7LFlsUEZFouuQiIlIRaugiIhWhhi4iUhFq6CIiFaGGLiJSEWroIiIVoYYuIlIR/w/2WVh/hLe5CQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[y==0,0], X[y==0,1])\n",
    "plt.scatter(X[y==1,0], X[y==1,1])\n",
    "plt.scatter(X[y==2,0], X[y==2,1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DecisionTreeClassifier(class_weight=None, criterion='entropy', max_depth=2,\n",
       "                       max_features=None, max_leaf_nodes=None,\n",
       "                       min_impurity_decrease=0.0, min_impurity_split=None,\n",
       "                       min_samples_leaf=1, min_samples_split=2,\n",
       "                       min_weight_fraction_leaf=0.0, presort=False,\n",
       "                       random_state=42, splitter='best')"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.tree import DecisionTreeClassifier\n",
    "\n",
    "dt_clf = DecisionTreeClassifier(max_depth=2, criterion=\"entropy\", random_state=42) #创建决策树分类器\n",
    "dt_clf.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_decision_boundary(model, axis):\n",
    "    \n",
    "    x0, x1 = np.meshgrid(\n",
    "        np.linspace(axis[0], axis[1], int((axis[1]-axis[0])*100)).reshape(-1, 1),\n",
    "        np.linspace(axis[2], axis[3], int((axis[3]-axis[2])*100)).reshape(-1, 1),\n",
    "    )\n",
    "    \n",
    "    #x0.ravel()将多维数组降位一维，\n",
    "    #np.r_是按列连接两个矩阵，就是把两矩阵上下相加，要求列数相等。\n",
    "    #np.c_是按行连接两个矩阵，就是把两矩阵左右相加，要求行数相等。\n",
    "    \n",
    "    X_new = np.c_[x0.ravel(), x1.ravel()]\n",
    "\n",
    "    y_predict = model.predict(X_new)\n",
    "    zz = y_predict.reshape(x0.shape)\n",
    "\n",
    "    from matplotlib.colors import ListedColormap\n",
    "    custom_cmap = ListedColormap(['#EF9A9A','#FFF59D','#90CAF9'])\n",
    "    \n",
    "    plt.contourf(x0, x1, zz, cmap=custom_cmap)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh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6iEhJlK6hm9k9ZjZiZi9mXUsSZrbCzB43s11m9pKZ3Zh1TXGZ2Xwze87MXghqvz3rmpIws24z+5mZ/V3WtTTKzH5lZj83s51mNpR1PY0yswEze8jMXgl+Bz6UdU1xmdmvBX/ukz9HzOymttZQtmvoZvYR4Chwn7tfnHU9jTKzZcAyd99hZv3AduAT7v5yxqXVFXw7uM/dj5pZL/AUcKO7P5NxaQ0xsz8ABoGF7n5N1vU0wsx+BQy6eyG/mGNm9wJPuvtdQapugbsfyrquRgVLpvwL8EF3f61dn1u6M3R3f4ICZ+DdfZ+77whejwK7qHwTN/e84miw2Rv8FOqMwcyWA+uAu7KupdOY2ULgI1RSc7j720Vs5oGPAv+vnc0cStjQy8TMVgKrgWezrSS+4HLFTmAE+JG7F6b2wP8A/ojiPojKgcfMbHuw1EaRvBd4A/hfwSWvu8ysqM93XA/c3+4PVUPPKTM7A9gC3OTuhVmv193H3X0VlW8UrzGzwlz2MrNrgBF33551LU1Y6+6/QWV11C8GlyCLogf4DeDb7r4aOAb8cbYlNS64VPRx4MF2f7Yaeg4F15+3AN9194ezrieJ4K/K/wBcmXEpjVgLfDy4Dv0A8Ftm9tfZltQYd98b/HME+D6V1VKLYhgYrvpb3UNUGnzRXAXscPf97f5gNfScCW4s3g3scvevZ11PI8xssZkNBK9PBz4GvJJtVfG5+83uvtzdV1L5K/NP3P0/ZlxWbGbWF9xIJ7hUcQVQmLSXu78O7DGzXwuGPgrkPgwQ4dNkcLkFSvgIOjO7H7gcWGRmw8Ct7n53tlU1ZC3wWeDnwbVogC+7+7YMa4prGXBvcIe/C/ieuxcu+ldg5wDfDx5F0AP8b3f/+2xLatiXgO8Gly1eBb6QcT0NMbMFwG8D/zmTzy9bbFFEpFPpkouISEmooYuIlIQauohISaihi4iUhBq6iEhJqKGLiJSEGrqISEn8fwoRWMTYJE5nAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_decision_boundary(dt_clf, axis=[0.5, 7.5, 0, 3]) #x坐标从0.5到7.5，y从0到3\n",
    "plt.scatter(X[y==0,0], X[y==0,1])\n",
    "plt.scatter(X[y==1,0], X[y==1,1])\n",
    "plt.scatter(X[y==2,0], X[y==2,1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
